<?php
namespace Home\Model;
//物品基础属性
class User{
    public $redis;
    public $username;
    public $container;
    public $city;
    public function __construct($username){
        //数据集
        $this->redis = getRedis();
        $this->username = $username;//用户名
        $this->container = new \Home\Model\Container($this);
        $this->city = $this->redis->hGet('users:'.$username, 'city');//保存城市
        if(!$this->city){
            $this->city = $username.'\'s City';
            $city = new \Home\Model\City($this);
            $city->initData();
            $this->redis->hSet('users:'.$username, 'city', $username.'\'s City');
        }
        
    }

    //初始化一个账号
    public function initData(){
        $money = new \Home\Model\Money($this);
        $money->initData();
        $shop = new \Home\Model\Shop($this);
        $shop->initData();
        $slot = new \Home\Model\Slot($this);
        $slot->initData();
        $goods = new \Home\Model\Goods($this, '刀');
        $goods->initData();
        $heart = new \Home\Model\Heart($this);
        $heart->initData();
        $bucket = new \Home\Model\Bucket($this);
        $bucket->initData();
        $worker = new \Home\Model\Worker($this);
        $worker->initData();
        $warehouse = new \Home\Model\Warehouse($this);
        $warehouse->initData();
    }
    
} 